/**
 * Copyright (C) 2012  The CFuture Android Ad-platform Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.lurencun.android.support.ad;

import com.lurencun.android.support.ad.i.DianJinAdSense;
import com.lurencun.android.support.ad.i.JuZiAdSense;
import com.lurencun.android.support.ad.i.YouMiAdSense;

import android.content.Context;

/**
 * 管理各个广告平台的实例创建。
 * <br/>
 * 通过统一接口，创建不同广告平台的实例对象。
 * @author cfuture.chenyoca [桥下一粒砂] (chenyoca@163.com)
 * @date 2012-3-2
 */
public final class AdManager {
	
	public enum AdType{
		JuZi,DianJin,YouMi
	};
	
	/**
	 * 取得某个具体广告平台的实例对象。
	 * @param context Context引用
	 * @param listener OnPayListener回调接口
	 * @param adType 广告平台类型。具体参见AdManager.AdType
	 * @param params 如果某个广告平台需要在代码中设置AppID和AppKey，可以使用此参数。<b>否则，此参数可以省略。</b>
	 * 			<br/>
	 * 			<li>点金广告平台是AppID，AppKey。</li>
	 * 			<li>有米广告平台是AppID，AppSecet。</li>
	 * @return 某个广告平台的实例对象。若对应类型的广告平台不存在则返回null。
	 */
	public static AdSense instanceAd(Context context,OnPayedListener listener,AdType adType,String...params){
		AdSense adInstance = null;
		if(adType.equals(AdType.JuZi)){
			adInstance = new JuZiAdSense(context, listener);
		}else if(adType.equals(AdType.DianJin)){
			adInstance = new DianJinAdSense(context, listener, Integer.valueOf(params[0]), params[1]);
		}else if(adType.equals(AdType.YouMi)){
			adInstance = new YouMiAdSense(context, listener, params[0], params[1]);
		}
		return adInstance;
	}
	
}
